/*
day84
2019.11.20
*/

#include<queue>
#include<vector>
using namespace std;

struct TreeNode {
	int val;
	struct TreeNode *left;
	struct TreeNode *right;
};


class Solution {
public:
    vector<int> rightSideView(TreeNode* root) {
    	vector<int> vec;
    	if(!root) return vec; 
    	
        queue<TreeNode *> que;
        que.push(root);
        TreeNode *cur;
        
        while(!que.empty())
        {
        	int num=que.size();
        	
        	vec.push_back( que.back()->val );
        	for(int i=0;i<num;i++)
        	{
        		cur=que.front();
        		que.pop();
        		if(cur->left) que.push(cur->left);
        		if(cur->right) que.push(cur->right);
			}
		}
		return vec;
    }
};


int main()
{
	return 0;
}
